﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Collections.Generic;
using System.Xml;


namespace Logic.SocialNetworks
{
	/// <summary>
	/// Summary description for Events
	/// </summary>
	public class Events : List<Event>
	{
		public Events(XmlDocument XmlDocument)
		{
			foreach (XmlElement item in XmlDocument.DocumentElement)
			{
				Event e = new Event(item);
				base.Add(e);

			}
		}
	}
	public class Event
	{
		#region Event Arguments

		/// <summary>
		/// The event title.
		/// </summary>
		public string Title { get; set; }
		/// <summary>
		/// Optional. The event description. Optional
		/// </summary>
		public string Description { get; set; }
		/// <summary>
		/// The event start date and time, in ISO 8601 format (e.g., "2007-12-31 23:59:59").
		/// </summary>
		public string StartDate { get; set; }
		/// <summary>
		/// The event end date and time, in ISO 8601 format (e.g., "2007-12-31 23:59:59").
		/// </summary>
		public string EndDate { get; set; }
		/// <summary>
		/// The event time zone in relation to GMT (e.g., "GMT+01", "GMT+02", "GMT-01").
		/// </summary>
		public string TimeZone { get; set; }
		/// <summary>
		/// Optional. 0 for a private event, 1 for a public event. If not provided, will default to 1. Optional
		/// </summary>
		public string Privacy { get; set; }
		/// <summary>
		/// Optional. The event registration URL. If you pass "testevent", the event will be accessible at "http://testevent.eventbrite.com".
		/// </summary>
		public string PersonalizedUrl { get; set; }
		/// <summary>
		/// Optional. The event venue ID. The venue must have been previously created.
		/// </summary>
		public int VenueId { get; set; }
		/// <summary>
		/// Optional. The event organizer ID. The organizer must have been previously created.
		/// </summary>
		public int OrganizerId { get; set; }
		/// <summary>
		/// Optional. The maximum number of people who can attend the event.
		/// </summary>
		public int Capacity { get; set; }
		/// <summary>
		/// Optional. The event currency in ISO 4217 format (e.g., "USD", "EUR").
		/// </summary>
		public string Currency { get; set; }
		/// <summary>
		/// Optional. The event status. Allowed values are "draft", "live" for new events. If not provided, status will be "draft", meaning that the event registration page will not be available publicly until you update the status.
		/// </summary>
		public string Status { get; set; }
		/// <summary>
		/// Optional. Custom HTML header for your registration page.
		/// </summary>
		public string CustomHeader { get; set; }
		/// <summary>
		/// Optional. Custom HTML footer for your registration page.
		/// </summary>
		public string CustomFooter { get; set; }
		/// <summary>
		/// Optional. Custom hexadecimal color for your registration page. Format: FFFFFF without  the pound
		/// </summary>
		public string BackgroundColor { get; set; }
		/// <summary>
		/// Optional. Custom hexadecimal color for your registration page. Format: FFFFFF without  the pound
		/// </summary>
		public string TextColor { get; set; }
		/// <summary>
		/// Optional. Custom hexadecimal color for your registration page. Format: FFFFFF without  the pound
		/// </summary>
		public string TitleTextColor { get; set; }
		/// <summary>
		/// Optional. Custom hexadecimal color for your registration page. Format: FFFFFF without  the pound
		/// </summary>
		public string BoxBackgroundColor { get; set; }
		/// <summary>
		/// Optional.Custom hexadecimal color for your registration page. Format: FFFFFF without  the pound
		/// </summary>
		public string BoxTextColor { get; set; }
		/// <summary>
		/// Optional. Custom hexadecimal color for your registration page. Format: FFFFFF without  the pound
		/// </summary>
		public string BoxBorderColor { get; set; }
		/// <summary>
		/// Optional. Custom hexadecimal color for your registration page. Format: FFFFFF without  the pound
		/// </summary>
		public string BoxHeaderBackgroundColor { get; set; }
		/// <summary>
		/// Optional. Custom hexadecimal color for your registration page. Format: FFFFFF without  the pound
		/// </summary>
		public string BoxHeaderTextColor { get; set; }
		/// <summary>
		/// The event ID.
		/// </summary>
		public int ID { get; set; }
		/// <summary>
		/// The event category
		/// </summary>
		public string Category { get; set; }
		/// <summary>
		/// The event tags/keywords
		/// </summary>
		public string Tags { get; set; }
		/// <summary>
		/// The date and time the event was created, in ISO 8601 format (e.g., "2007-12-31 23:59:59")
		/// </summary>
		public string Created { get; set; }
		/// <summary>
		/// The date and time the event was last modified, in ISO 8601 format (e.g., "2007-12-31 23:59:59")
		/// </summary>
		public string Modified { get; set; }
		/// <summary>
		/// Reserved for private event only
		/// </summary>
		public string Password { get; set; }
		/// <summary>
		/// The event registration URL
		/// </summary>
		public string Url { get; set; }
		/// <summary>
		/// The event logo URL
		/// </summary>
		public string Logo { get; set; }
		/// <summary>
		/// The event logo URL for secure applications
		/// </summary>
		public string LogoSSL { get; set; }
		/// <summary>
		/// Custom hexadecimal color for your registration page. Format: FFFFFF without  the pound
		/// </summary>
		public string LinkColor { get; set; }
		#endregion

		public Venue Venue { get; set; }
		public Organizer Organizer { get; set; }
		public Tickets Tickets { get; set; }

		/// <summary>
		/// This constructor will create an array of events
		/// </summary>
		/// <param name="XmlElement"></param>
		internal Event(XmlElement XmlElement)
		{
			CreateEvent(XmlElement);
		}
		/// <summary>
		/// This constructor will create an event
		/// </summary>
		/// <param name="XmlDocument"></param>
		public Event(XmlDocument XmlDocument)
		{
			CreateEvent(XmlDocument.DocumentElement);
		}

		private void CreateEvent(XmlElement XmlElement)
		{
			foreach (XmlElement item in XmlElement)
			{
				switch (item.Name)
				{
					case "id":
						this.ID = Convert.ToInt32(item.InnerText);
						break;
					case "title":
						this.Title = item.InnerText;
						break;
					case "description":
						this.Description = item.InnerText;
						break;
					case "category":
						this.Category = item.InnerText;
						break;
					case "tags":
						this.Tags = item.InnerText;
						break;
					case "start_date":
						this.StartDate = item.InnerText;
						break;
					case "end_date":
						this.EndDate = item.InnerText;
						break;
					case "timezone":
						this.TimeZone = item.InnerText;
						break;
					case "created":
						this.Created = item.InnerText;
						break;
					case "modified":
						this.Modified = item.InnerText;
						break;
					case "privacy":
						this.Privacy = item.InnerText;
						break;
					case "password":
						this.Password = item.InnerText;
						break;
					case "capacity":
						this.Capacity = Convert.ToInt32(item.InnerText);
						break;
					case "url":
						this.Url = item.InnerText;
						break;
					case "logo":
						this.Logo = item.InnerText;
						break;
					case "logo_ssl":
						this.LogoSSL = item.InnerText;
						break;
					case "status":
						this.Status = item.InnerText;
						break;
					case "background_color":
						this.BackgroundColor = item.InnerText;
						break;
					case "text_color":
						this.TextColor = item.InnerText;
						break;
					case "link_color":
						this.LinkColor = item.InnerText;
						break;
					case "title_text_color":
						this.TitleTextColor = item.InnerText;
						break;
					case "box_background_color":
						this.BoxBackgroundColor = item.InnerText;
						break;
					case "box_text_color":
						this.BoxTextColor = item.InnerText;
						break;
					case "box_border_color":
						this.BoxBorderColor = item.InnerText;
						break;
					case "box_header_background_color":
						this.BoxHeaderBackgroundColor = item.InnerText;
						break;
					case "box_header_text_color":
						this.BoxHeaderTextColor = item.InnerText;
						break;
					case "venue":
						this.Venue = new Venue(item);
						break;
					case "organizer":
						this.Organizer = new Organizer(item);
						break;
					case "tickets":
                        this.Tickets = new Tickets(item);
                        break;
					default:
						break;
				}
			}
		}       
	}
}
